package com.whb.event;

import java.util.ArrayList;
import java.util.EventListener;
import java.util.EventObject;
import java.util.List;

/**
 * @Author labu
 * @Date 2020/11/26
 * @Description
 */
public class MyEventSource {
    private List<MyListener> listeners =new ArrayList<>();

    public void addListener(MyListener eventListener){
        listeners.add(eventListener);
    }

    public void removeListener(MyListener eventListener){
        listeners.remove(eventListener);
    }

    //触发listener的回调
    public void notifyListeners(final MyEventObject event){
        listeners.forEach(e->e.handleEvent(event));
    }

    public void onQueryFail(MyListener listener){
        listeners.add(listener);
    }

    public void onCheckFail(){

    }
}
